package org.jgs1904.publisherandlistener.publisher;

import org.jgs1904.publisherandlistener.event.MyTestEvent;
import org.jgs1904.publisherandlistener.event.MyTestEvent2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

/**
 * 事件发布
 *
 * @author: 默苍璃
 * @date: 2023-11-03 18:35
 */
@Component
public class MyTestEventPubLisher {

    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;

    /**
     * 事件发布方法
     */
    public void pushListener(String msg) {
        applicationEventPublisher.publishEvent(new MyTestEvent(this, msg));
        applicationEventPublisher.publishEvent(new MyTestEvent2(msg));
    }

}

